import hashlib
import os


def get_hash(paths):
    # Returns a single hash value of a list of paths (files or dirs)
    size = sum(os.path.getsize(p) for p in paths if os.path.exists(p))  # size 文件占用字节数
    h = hashlib.md5(str(size).encode())  # hash sizes
    h.update(''.join(paths).encode())  # hash paths 会拼接之前的明文
    return h.hexdigest()  # return hash

if __name__ =='__main__':

    get_hash([r'D:\data\231207huoni\trainseg_screw\add_imgs'])